/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufsc.aps.jogodavida.view;

import br.ufsc.aps.jogodavida.control.AtorJogador;
import java.awt.CardLayout;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class Frame extends JFrame {

    private AtorJogador jogador;
    private CardLayout layout;

    private void initPanels() {
        layout.layoutContainer(this.getContentPane());
        
        PanelConnect cp = new PanelConnect(this);        
        layout.addLayoutComponent(cp, "Connect");
        this.add(cp);
        
        PanelTabuleiro pt = new PanelTabuleiro(this);        
        layout.addLayoutComponent(pt, "Tabuleiro");
        this.add(pt);
        
        this.repaint();
        changePanels("Connect");
    }

    public Frame() {
        super("Jogo da Vida");
        layout = new CardLayout();
        jogador = new AtorJogador();
        this.getContentPane().setLayout(layout);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(900, 650);
        this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.initPanels();
    }

    /**
     * @return the jogador
     */
    protected AtorJogador getJogador() {
        return jogador;
    }

    /**
     * @param jogador the jogador to set
     */
    protected void setJogador(AtorJogador jogador) {
        this.jogador = jogador;
    }

    public void changePanels(String nome) {
        CardLayout cl = (CardLayout) this.getContentPane().getLayout();
        cl.show(this.getContentPane(), nome);
    }
    
    public static void main(String[] args) {
        try {
            //system platform L&F
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
            // handle exception
        } catch (ClassNotFoundException e) {
            // handle exception
        } catch (InstantiationException e) {
            // handle exception
        } catch (IllegalAccessException e) {
            // handle exception
        }
        Frame f = new Frame();
        f.setVisible(true);

    }
}
